
_UpdatePID:

;PID [John].c,10 :: 		double UpdatePID(SPid * pid, double error, double position){
;PID [John].c,13 :: 		pTerm = pid->pGain * error;      // calculate the proportional term
	MOVLW      16
	ADDWF      FARG_UpdatePID_pid+0, 0
	MOVWF      FSR
	MOVF       INDF+0, 0
	MOVWF      R0+0
	INCF       FSR, 1
	MOVF       INDF+0, 0
	MOVWF      R0+1
	INCF       FSR, 1
	MOVF       INDF+0, 0
	MOVWF      R0+2
	INCF       FSR, 1
	MOVF       INDF+0, 0
	MOVWF      R0+3
	MOVF       FARG_UpdatePID_error+0, 0
	MOVWF      R4+0
	MOVF       FARG_UpdatePID_error+1, 0
	MOVWF      R4+1
	MOVF       FARG_UpdatePID_error+2, 0
	MOVWF      R4+2
	MOVF       FARG_UpdatePID_error+3, 0
	MOVWF      R4+3
	CALL       _Mul_32x32_FP+0
	MOVF       R0+0, 0
	MOVWF      UpdatePID_pTerm_L0+0
	MOVF       R0+1, 0
	MOVWF      UpdatePID_pTerm_L0+1
	MOVF       R0+2, 0
	MOVWF      UpdatePID_pTerm_L0+2
	MOVF       R0+3, 0
	MOVWF      UpdatePID_pTerm_L0+3
;PID [John].c,14 :: 		pid->iState += error;            // calculate the integral state with appropriate limiting
	MOVLW      4
	ADDWF      FARG_UpdatePID_pid+0, 0
	MOVWF      FLOC__UpdatePID+0
	MOVF       FLOC__UpdatePID+0, 0
	MOVWF      FSR
	MOVF       INDF+0, 0
	MOVWF      R0+0
	INCF       FSR, 1
	MOVF       INDF+0, 0
	MOVWF      R0+1
	INCF       FSR, 1
	MOVF       INDF+0, 0
	MOVWF      R0+2
	INCF       FSR, 1
	MOVF       INDF+0, 0
	MOVWF      R0+3
	MOVF       FARG_UpdatePID_error+0, 0
	MOVWF      R4+0
	MOVF       FARG_UpdatePID_error+1, 0
	MOVWF      R4+1
	MOVF       FARG_UpdatePID_error+2, 0
	MOVWF      R4+2
	MOVF       FARG_UpdatePID_error+3, 0
	MOVWF      R4+3
	CALL       _Add_32x32_FP+0
	MOVF       FLOC__UpdatePID+0, 0
	MOVWF      FSR
	MOVF       R0+0, 0
	MOVWF      INDF+0
	MOVF       R0+1, 0
	INCF       FSR, 1
	MOVWF      INDF+0
	MOVF       R0+2, 0
	INCF       FSR, 1
	MOVWF      INDF+0
	MOVF       R0+3, 0
	INCF       FSR, 1
	MOVWF      INDF+0
;PID [John].c,16 :: 		if (pid->iState > pid->iMax)
	MOVLW      4
	ADDWF      FARG_UpdatePID_pid+0, 0
	MOVWF      FSR
	MOVF       INDF+0, 0
	MOVWF      R4+0
	INCF       FSR, 1
	MOVF       INDF+0, 0
	MOVWF      R4+1
	INCF       FSR, 1
	MOVF       INDF+0, 0
	MOVWF      R4+2
	INCF       FSR, 1
	MOVF       INDF+0, 0
	MOVWF      R4+3
	MOVLW      8
	ADDWF      FARG_UpdatePID_pid+0, 0
	MOVWF      FSR
	MOVF       INDF+0, 0
	MOVWF      R0+0
	INCF       FSR, 1
	MOVF       INDF+0, 0
	MOVWF      R0+1
	INCF       FSR, 1
	MOVF       INDF+0, 0
	MOVWF      R0+2
	INCF       FSR, 1
	MOVF       INDF+0, 0
	MOVWF      R0+3
	CALL       _Compare_Double+0
	MOVLW      1
	BTFSC      STATUS+0, 0
	MOVLW      0
	MOVWF      R0+0
	MOVF       R0+0, 0
	BTFSC      STATUS+0, 2
	GOTO       L_UpdatePID0
;PID [John].c,17 :: 		pid->iState = pid->iMax;
	MOVLW      4
	ADDWF      FARG_UpdatePID_pid+0, 0
	MOVWF      R4+0
	MOVLW      8
	ADDWF      FARG_UpdatePID_pid+0, 0
	MOVWF      FSR
	MOVF       INDF+0, 0
	MOVWF      R0+0
	INCF       FSR, 1
	MOVF       INDF+0, 0
	MOVWF      R0+1
	INCF       FSR, 1
	MOVF       INDF+0, 0
	MOVWF      R0+2
	INCF       FSR, 1
	MOVF       INDF+0, 0
	MOVWF      R0+3
	MOVF       R4+0, 0
	MOVWF      FSR
	MOVF       R0+0, 0
	MOVWF      INDF+0
	MOVF       R0+1, 0
	INCF       FSR, 1
	MOVWF      INDF+0
	MOVF       R0+2, 0
	INCF       FSR, 1
	MOVWF      INDF+0
	MOVF       R0+3, 0
	INCF       FSR, 1
	MOVWF      INDF+0
	GOTO       L_UpdatePID1
L_UpdatePID0:
;PID [John].c,18 :: 		else if (pid->iState<pid->iMin)
	MOVLW      4
	ADDWF      FARG_UpdatePID_pid+0, 0
	MOVWF      FSR
	MOVF       INDF+0, 0
	MOVWF      R4+0
	INCF       FSR, 1
	MOVF       INDF+0, 0
	MOVWF      R4+1
	INCF       FSR, 1
	MOVF       INDF+0, 0
	MOVWF      R4+2
	INCF       FSR, 1
	MOVF       INDF+0, 0
	MOVWF      R4+3
	MOVLW      12
	ADDWF      FARG_UpdatePID_pid+0, 0
	MOVWF      FSR
	MOVF       INDF+0, 0
	MOVWF      R0+0
	INCF       FSR, 1
	MOVF       INDF+0, 0
	MOVWF      R0+1
	INCF       FSR, 1
	MOVF       INDF+0, 0
	MOVWF      R0+2
	INCF       FSR, 1
	MOVF       INDF+0, 0
	MOVWF      R0+3
	MOVF       R4+0, 0
	MOVWF      R0+0
	MOVF       R4+1, 0
	MOVWF      R0+1
	MOVF       R4+2, 0
	MOVWF      R0+2
	MOVF       R4+3, 0
	MOVWF      R0+3
	MOVF       R0+0, 0
	MOVWF      R4+0
	MOVF       R0+1, 0
	MOVWF      R4+1
	MOVF       R0+2, 0
	MOVWF      R4+2
	MOVF       R0+3, 0
	MOVWF      R4+3
	CALL       _Compare_Double+0
	MOVLW      1
	BTFSC      STATUS+0, 0
	MOVLW      0
	MOVWF      R0+0
	MOVF       R0+0, 0
	BTFSC      STATUS+0, 2
	GOTO       L_UpdatePID2
;PID [John].c,19 :: 		pid->iState = pid->iMin;
	MOVLW      4
	ADDWF      FARG_UpdatePID_pid+0, 0
	MOVWF      R4+0
	MOVLW      12
	ADDWF      FARG_UpdatePID_pid+0, 0
	MOVWF      FSR
	MOVF       INDF+0, 0
	MOVWF      R0+0
	INCF       FSR, 1
	MOVF       INDF+0, 0
	MOVWF      R0+1
	INCF       FSR, 1
	MOVF       INDF+0, 0
	MOVWF      R0+2
	INCF       FSR, 1
	MOVF       INDF+0, 0
	MOVWF      R0+3
	MOVF       R4+0, 0
	MOVWF      FSR
	MOVF       R0+0, 0
	MOVWF      INDF+0
	MOVF       R0+1, 0
	INCF       FSR, 1
	MOVWF      INDF+0
	MOVF       R0+2, 0
	INCF       FSR, 1
	MOVWF      INDF+0
	MOVF       R0+3, 0
	INCF       FSR, 1
	MOVWF      INDF+0
L_UpdatePID2:
L_UpdatePID1:
;PID [John].c,21 :: 		iTerm = pid->iGain * pid->iState;    // calculate the integral term
	MOVLW      20
	ADDWF      FARG_UpdatePID_pid+0, 0
	MOVWF      FSR
	MOVF       INDF+0, 0
	MOVWF      R4+0
	INCF       FSR, 1
	MOVF       INDF+0, 0
	MOVWF      R4+1
	INCF       FSR, 1
	MOVF       INDF+0, 0
	MOVWF      R4+2
	INCF       FSR, 1
	MOVF       INDF+0, 0
	MOVWF      R4+3
	MOVLW      4
	ADDWF      FARG_UpdatePID_pid+0, 0
	MOVWF      FSR
	MOVF       INDF+0, 0
	MOVWF      R0+0
	INCF       FSR, 1
	MOVF       INDF+0, 0
	MOVWF      R0+1
	INCF       FSR, 1
	MOVF       INDF+0, 0
	MOVWF      R0+2
	INCF       FSR, 1
	MOVF       INDF+0, 0
	MOVWF      R0+3
	CALL       _Mul_32x32_FP+0
	MOVF       R0+0, 0
	MOVWF      UpdatePID_iTerm_L0+0
	MOVF       R0+1, 0
	MOVWF      UpdatePID_iTerm_L0+1
	MOVF       R0+2, 0
	MOVWF      UpdatePID_iTerm_L0+2
	MOVF       R0+3, 0
	MOVWF      UpdatePID_iTerm_L0+3
;PID [John].c,22 :: 		dTerm = pid->dGain * (position - pid->dState);
	MOVLW      24
	ADDWF      FARG_UpdatePID_pid+0, 0
	MOVWF      FSR
	MOVF       INDF+0, 0
	MOVWF      FLOC__UpdatePID+0
	INCF       FSR, 1
	MOVF       INDF+0, 0
	MOVWF      FLOC__UpdatePID+1
	INCF       FSR, 1
	MOVF       INDF+0, 0
	MOVWF      FLOC__UpdatePID+2
	INCF       FSR, 1
	MOVF       INDF+0, 0
	MOVWF      FLOC__UpdatePID+3
	MOVF       FARG_UpdatePID_pid+0, 0
	MOVWF      FSR
	MOVF       INDF+0, 0
	MOVWF      R4+0
	INCF       FSR, 1
	MOVF       INDF+0, 0
	MOVWF      R4+1
	INCF       FSR, 1
	MOVF       INDF+0, 0
	MOVWF      R4+2
	INCF       FSR, 1
	MOVF       INDF+0, 0
	MOVWF      R4+3
	MOVF       FARG_UpdatePID_position+0, 0
	MOVWF      R0+0
	MOVF       FARG_UpdatePID_position+1, 0
	MOVWF      R0+1
	MOVF       FARG_UpdatePID_position+2, 0
	MOVWF      R0+2
	MOVF       FARG_UpdatePID_position+3, 0
	MOVWF      R0+3
	CALL       _Sub_32x32_FP+0
	MOVF       FLOC__UpdatePID+0, 0
	MOVWF      R4+0
	MOVF       FLOC__UpdatePID+1, 0
	MOVWF      R4+1
	MOVF       FLOC__UpdatePID+2, 0
	MOVWF      R4+2
	MOVF       FLOC__UpdatePID+3, 0
	MOVWF      R4+3
	CALL       _Mul_32x32_FP+0
	MOVF       R0+0, 0
	MOVWF      UpdatePID_dTerm_L0+0
	MOVF       R0+1, 0
	MOVWF      UpdatePID_dTerm_L0+1
	MOVF       R0+2, 0
	MOVWF      UpdatePID_dTerm_L0+2
	MOVF       R0+3, 0
	MOVWF      UpdatePID_dTerm_L0+3
;PID [John].c,23 :: 		pid->dState = position;
	MOVF       FARG_UpdatePID_pid+0, 0
	MOVWF      FSR
	MOVF       FARG_UpdatePID_position+0, 0
	MOVWF      INDF+0
	MOVF       FARG_UpdatePID_position+1, 0
	INCF       FSR, 1
	MOVWF      INDF+0
	MOVF       FARG_UpdatePID_position+2, 0
	INCF       FSR, 1
	MOVWF      INDF+0
	MOVF       FARG_UpdatePID_position+3, 0
	INCF       FSR, 1
	MOVWF      INDF+0
;PID [John].c,24 :: 		return pTerm + iTerm - dTerm;
	MOVF       UpdatePID_pTerm_L0+0, 0
	MOVWF      R0+0
	MOVF       UpdatePID_pTerm_L0+1, 0
	MOVWF      R0+1
	MOVF       UpdatePID_pTerm_L0+2, 0
	MOVWF      R0+2
	MOVF       UpdatePID_pTerm_L0+3, 0
	MOVWF      R0+3
	MOVF       UpdatePID_iTerm_L0+0, 0
	MOVWF      R4+0
	MOVF       UpdatePID_iTerm_L0+1, 0
	MOVWF      R4+1
	MOVF       UpdatePID_iTerm_L0+2, 0
	MOVWF      R4+2
	MOVF       UpdatePID_iTerm_L0+3, 0
	MOVWF      R4+3
	CALL       _Add_32x32_FP+0
	MOVF       UpdatePID_dTerm_L0+0, 0
	MOVWF      R4+0
	MOVF       UpdatePID_dTerm_L0+1, 0
	MOVWF      R4+1
	MOVF       UpdatePID_dTerm_L0+2, 0
	MOVWF      R4+2
	MOVF       UpdatePID_dTerm_L0+3, 0
	MOVWF      R4+3
	CALL       _Sub_32x32_FP+0
;PID [John].c,25 :: 		}
	RETURN
; end of _UpdatePID

_main:

;PID [John].c,33 :: 		void main() {
;PID [John].c,35 :: 		}
	GOTO       $+0
; end of _main
